public class Test {
    public static void main(String args[]) {

    }
}
class Solution1 {
    public String truncateSentence(String s, int k) {
String[] str=new String[500];
str=s.split(" ");
StringBuilder str1=new StringBuilder();
        for (int i = 0; i < k; i++) {
            str1.append(str[i]);
            if(i<k-1)
            str1.append(" ");
        }
        String str2=new String(str1);
return str2;
    }
}
